package com.yizhubao.app.activitys.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yizhubao.app.R;
import com.yizhubao.app.activitys.release.ReleaseActivity;
import com.yizhubao.app.adapters.ExampleImageAdapter;
import com.yizhubao.app.base.BaseActivityToolBar;
import com.yizhubao.app.utils.Constants;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import h.framework.pacy.utils.ScreenUtil;
import h.framework.pacy.views.recyclerview.DividerDecoration;

/**
 * 创建人: PACY
 * 创建时间: 6/6/21 10:25 AM
 * 邮箱: pengwwe457621023@qq.com
 * 类描述: 日常记录案例
 */
public class ExampleActivity extends BaseActivityToolBar {


    @BindView(R.id.pageOneNext_tv)
    TextView pageOneNext_tv;
    @BindView(R.id.pageTwo_lin)
    LinearLayout pageTwo_lin;
    @BindView(R.id.pageTwoFirst_tv)
    TextView pageTwoFirst_tv;
    @BindView(R.id.pageTwoNext_tv)
    TextView pageTwoNext_tv;

    @BindView(R.id.example_tv)
    TextView example_tv;
    @BindView(R.id.image_iv)
    ImageView image_iv;
    @BindView(R.id.scroll_sv)
    NestedScrollView scroll_sv;

    List<String> examples;

    //案例页码
    private int page = 0;

    @Override
    protected int setContentLayout() {
        return R.layout.activity_example;
    }

    @Override
    protected void initView() {
        setTitleOnLeftIcon("案例1/5");
    }

    @Override
    protected void initData() {
        examples=new ArrayList<>();
        examples.add(getResources().getString(R.string.example_text1));
        examples.add(getResources().getString(R.string.example_text2));
        examples.add(getResources().getString(R.string.example_text3));
        examples.add(getResources().getString(R.string.example_text4));
        examples.add(getResources().getString(R.string.example_text5));
        example_tv.setText(examples.get(page));
        image_iv.setVisibility(View.GONE);
    }


    @OnClick(value = {R.id.pageOneNext_tv, R.id.pageTwoFirst_tv, R.id.pageTwoNext_tv,R.id.start_tv})
    public void click(View v) {
        if (v.getId() == R.id.pageOneNext_tv) {
            //第一页下一步
            if(page==0){
                page=1;
            }else if(page==4){
                page=3;
            }

        } else if (v.getId() == R.id.pageTwoFirst_tv) {
            //上一步
            page--;
        } else if (v.getId() == R.id.pageTwoNext_tv) {
            //下一步
            page++;
            //开始记录
        } else if(v.getId()==R.id.start_tv){
            startActivity(ExampleActivity.this, ReleaseActivity.class);
        }
        setPageView();
    }

    /**
     * 根据页码设置页面和数据
     */
    private void setPageView() {
        switch (page) {
            case 0:
                pageOneNext_tv.setVisibility(View.VISIBLE);
                pageOneNext_tv.setText("下一个案例");
                pageTwo_lin.setVisibility(View.GONE);
                image_iv.setVisibility(View.GONE);
                example_tv.setText(getResources().getString(R.string.example_text1));
                setTitleOnLeftIcon("案例1/5");
                break;
            case 1:
                pageOneNext_tv.setVisibility(View.GONE);
                pageTwo_lin.setVisibility(View.VISIBLE);
                image_iv.setVisibility(View.GONE);
                example_tv.setText(getResources().getString(R.string.example_text2));
                setTitleOnLeftIcon("案例2/5");
                break;
            case 2:
                pageOneNext_tv.setVisibility(View.GONE);
                pageTwo_lin.setVisibility(View.VISIBLE);
                image_iv.setVisibility(View.GONE);
                example_tv.setText(getResources().getString(R.string.example_text3));
                setTitleOnLeftIcon("案例3/5");
                break;
            case 3:
                pageOneNext_tv.setVisibility(View.GONE);
                pageTwo_lin.setVisibility(View.VISIBLE);
                image_iv.setVisibility(View.GONE);
                example_tv.setText(getResources().getString(R.string.example_text4));
                setTitleOnLeftIcon("案例4/5");
                break;
            case 4:
                pageOneNext_tv.setVisibility(View.VISIBLE);
                pageOneNext_tv.setText("上一个案例");
                pageTwo_lin.setVisibility(View.GONE);
                image_iv.setVisibility(View.VISIBLE);
                example_tv.setText(getResources().getString(R.string.example_text5));
                setTitleOnLeftIcon("案例5/5");
                break;
        }
        scroll_sv.fullScroll(View.FOCUS_UP);
    }


}